package com.enlorenz.core.engine.imp.quartz;

import com.enlorenz.core.engine.AbstractBuzHandler;

/**
 * 快速Quartz表达式
 * @author lcb
 */
public abstract class QuickQuartzEngine extends QuartzEngine{
	{
		buzHandler=new AbstractBuzHandler() {
			@Override
			protected void buzHandleImp() throws Exception {
				QuickQuartzEngine.this.handle();
			}
			
			protected void onExceptionHappened(Exception e){
				QuickQuartzEngine.this.onExceptionHappened(e);
			}
			
			protected void onFinallyDo(){
				QuickQuartzEngine.this.onFinallyDo();
			}
		};
	}
	
	/**
	 * 处理业务
	 * @throws Exception
	 */
	protected abstract void handle() throws Exception;
	
	/**
	 * 发生异常后
	 * @param e
	 */
	protected void onExceptionHappened(Exception e){
		
	}
	
	/**
	 * 一个循环完成始终要做的
	 * @param e
	 */
	protected void onFinallyDo(){
		
	}
	
	public static void main(String[] args) {
		System.out.println("in");
		QuickQuartzEngine eng=new QuickQuartzEngine(){

			@Override
			protected void handle() throws Exception {
				System.out.println("hello123");
			}
			
		};
		eng.setImmeStart(true);
		eng.setCronExpression("* * 0,1,2,23 * * ? ");
		eng.init();
		eng.start();
	}
}
